package com.milhouz.pokertimer;

import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.util.Log;

import com.milhouz.pokertimer.constant.LogConstant;

/**
 * Example that shows finding a preference from the hierarchy and a custom preference type.
 */
public class PokerTimerSettings extends PreferenceActivity implements OnSharedPreferenceChangeListener {

	public static final String APP_SETTINGS = "APP_SETTINGS";
	
	public Preference settingActivateSounds;
	public Preference settingActivateVibrate;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		Log.i(LogConstant.LOG_TAG, "onCreate : settings.");

		// initialize preferences screen
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.settings);
		
		getPreferenceManager().setSharedPreferencesName(APP_SETTINGS);
		getPreferenceManager().setSharedPreferencesMode(MODE_PRIVATE);
		
		// retrieve components
		settingActivateSounds = (Preference) getPreferenceScreen().findPreference("activateSounds");
		settingActivateVibrate = (Preference) getPreferenceScreen().findPreference("activateVibrate");
		
	}

	public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {

	}
	
   @Override
   protected void onResume() {
       super.onResume();
       getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
   }

   @Override
   protected void onPause() {
       super.onPause();
       getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
   }

}
